<?php // $Id$
/**
 * Capability definitions for the questionnaire module.
 *
 * For naming conventions, see lib/db/access.php.
 */
$mod_questionnaire_capabilities = array(

    // Ability to see that the questionnaire exists, and the basic information
    // about it.
    'mod/questionnaire:view' => array(

        'captype' => 'read',
        'contextlevel' => CONTEXT_MODULE,
        'legacy' => array(
            'student' => CAP_ALLOW,
            'teacher' => CAP_ALLOW,
            'editingteacher' => CAP_ALLOW,
            'admin' => CAP_ALLOW
        )
    ),

    // Ability to do the questionnaire as a 'student'.
    'mod/questionnaire:submit' => array(

        'captype' => 'write',
        'contextlevel' => CONTEXT_MODULE,
        'legacy' => array(
            'student' => CAP_ALLOW,
            'admin' => CAP_ALLOW
        )
    ),
    
    // Ability to view individual responses to the questionnaire.
    'mod/questionnaire:viewsingleresponse' => array(

        'captype' => 'read',
        'contextlevel' => CONTEXT_MODULE,
        'legacy' => array(
            'teacher' => CAP_ALLOW,
            'editingteacher' => CAP_ALLOW,
            'admin' => CAP_ALLOW
         )
    ),
    
    // Ability to download responses in a CSV file.
    'mod/questionnaire:downloadresponses' => array(

        'captype' => 'read',
        'contextlevel' => CONTEXT_MODULE,
        'legacy' => array(
            'teacher' => CAP_ALLOW,
            'editingteacher' => CAP_ALLOW,
            'admin' => CAP_ALLOW
        )
    ),
    
    // Ability to delete someone's (or own) previous responses.
    'mod/questionnaire:deleteresponses' => array(

        'captype' => 'write',
        'contextlevel' => CONTEXT_MODULE,
        'legacy' => array(
            'editingteacher' => CAP_ALLOW,
            'admin' => CAP_ALLOW
        )
    ),
    
    // Ability to edit survey questions.
    'mod/questionnaire:editquestions' => array(

        'captype' => 'write',
        'contextlevel' => CONTEXT_MODULE,
        'legacy' => array(
            'editingteacher' => CAP_ALLOW,
            'admin' => CAP_ALLOW
        )
    ),
   
    // Ability to create template surveys which can be copied, but not used.
    'mod/questionnaire:createtemplates' => array(

        'captype' => 'write',
        'contextlevel' => CONTEXT_MODULE,
        'legacy' => array(
            'admin' => CAP_ALLOW
        )
    ),
   
    // Ability to create public surveys which can be accessed from multiple places.
    'mod/questionnaire:createpublic' => array(

        'captype' => 'write',
        'contextlevel' => CONTEXT_MODULE,
        'legacy' => array(
            'admin' => CAP_ALLOW
        )
    ),

    // Ability to copy template surveys (or private ones from within same course).
    'mod/questionnaire:copysurveys' => array(

        'captype' => 'write',
        'contextlevel' => CONTEXT_MODULE,
        'legacy' => array(
            'editingteacher' => CAP_ALLOW,
            'admin' => CAP_ALLOW
        )
    ),
    
    // Ability to read own previous responses to questionnaires.
    'mod/questionnaire:readownresponses' => array(

        'captype' => 'read',
        'contextlevel' => CONTEXT_MODULE,
        'legacy' => array(
            'admin' => CAP_ALLOW,
            'student' => CAP_ALLOW
        )
    ),
    
    // Ability to read others' previous responses to questionnaires.
    // Subject to constraints on whether responses can be viewed whilst
    // questionnaire still open or user has not yet responded themselves.   
    'mod/questionnaire:readallresponses' => array(

        'captype' => 'read',
        'contextlevel' => CONTEXT_MODULE,
        'legacy' => array(
            'admin' => CAP_ALLOW,
            'teacher' => CAP_ALLOW,
            'editingteacher' => CAP_ALLOW
        )
    ),
    
    // Ability to read others's responses without the above checks.
    'mod/questionnaire:readallresponseanytime' => array(

        'captype' => 'read',
        'contextlevel' => CONTEXT_MODULE,
        'legacy' => array(
            'admin' => CAP_ALLOW,
            'teacher' => CAP_ALLOW,
            'editingteacher' => CAP_ALLOW
        )
    )
    
);

?>
